package com.cn.zpark;

import com.alibaba.fastjson.JSON;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: JavaBeanToJson
 * @Description:将JavaBean转为json字符串
 * @author: RZS
 * @date: 2022/4/29  19:16
 */
public class JavaBeanToJson {
    public static void main(String[] args) {
        // 创建user对象
        User user = new User();
        user.setId(1);
        user.setName("大锤");
        user.setPwd("88888888");
        System.out.println(user);

        // 将user对象转换为json字符串
        String jsonString = JSON.toJSONString(user);
        System.out.println(jsonString);
    }
}
